package com.bafa.objects;

import com.bafa.dbcache.LeagueCache;

import java.io.Serializable;
import java.util.*;

import com.bafa.dbcache.RetrieveCache;
import com.bafa.services.RetrieveServices;
import com.bafa.util.comparators.MatchByDateComparator;

public class Round implements Serializable{

	private String name; 
	private boolean cup;
	private int ID;
	private int previousRound;
	private boolean confirmed;
	
	private List matches = new ArrayList();
	
	public Round(com.bafa.objects.schema.Round round){
		this(round.getName(),round.isCup(),round.getID(),round.getPreviousRound(),round.isConfirmed());
		for(int i=0;i<round.getMatches().size();i++){
			addMatch(round.getMatches().get(i));
		}
	}
	public Round(String name, boolean cup, int ID,int previousRound, boolean confirmed){
		this.name = name;
		this.cup = cup;
		this.ID = ID;
		this.previousRound = previousRound;
		this.confirmed=confirmed;
	}
	public boolean isCup() {
		return cup;
	}
	public int getID() {
		return ID;
	}
	public String getName() {
		return name;
	}
	
	public void addMatch(int match){
		matches.add(match);
	}
	public List getMatches() {
		return matches;
	}
	public int getPreviousRound() {
		return previousRound;
	}
	
	public Match[] matchArray(){
		Match[] matchArray = new Match[matches.size()];
		for(int i=0;i<matches.size();i++){
			Match match = (Match)LeagueCache.getMatches().get((Integer)matches.get(i));
			matchArray[i]=match;
		}
		
		return matchArray;
	}
	
	
	
	public boolean isConfirmed() {
		return confirmed;
	}
	
	
}
